package 笔试2.美团.one;


import java.util.*;

/*
2
4 2 3
1 2
2 3
1 2 3
4 2 3
1 2
2 3
1 2 4
 */
//--map并查集 用string妙
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int T = sc.nextInt();
        for (int t = 0; t < T; t++) {
            int a=sc.nextInt(),b=sc.nextInt(),c=sc.nextInt();
            int[] p = new int[c];

            List<int[]> xyList = new ArrayList<>();
            for (int i = 0; i < b; i++) {
                xyList.add(new int[]{sc.nextInt(),sc.nextInt()});
            }
            for (int i = 0; i < c; i++) {
                p[i]=sc.nextInt();
            }

            Set<String> set = new HashSet<>();
            for (int i = 0; i < xyList.size(); i++) {
                String z= xyList.get(i)[0]+" "+xyList.get(i)[1];
                String f =xyList.get(i)[1]+" "+xyList.get(i)[0];
                set.add(z);
                set.add(f);
            }


            int fg=0;
            for (int i = 0; i < p.length - 1; i++) {
                String z = p[i]+" "+p[i+1];
                String f = p[i+1]+" "+p[i];
                if(!set.contains(z)&&!set.contains(f)){
                    System.out.println("NO");
                    fg=1;
                    break;
                }
            }
            if(fg==0) {
                System.out.println("YES");
            }
//            System.out.println(1);
        }

    }
}
